#include "gtest/gtest.h"

#include "DataStructure/Input/Coordinate/CORD2SData.h"
#include "DataStructure/Input/Coordinate/ICoordinate.h"

using namespace SG::DataStructure::FEM;
using SG::Algebra::Point;
using SG::Algebra::Vector3D;
using SG::DataStructure::Common::PI;
using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::Sphere2Coord;

TEST (Sphere2CoordTest, Sphere2CoordComputeTrans2Basic)
{
    // Input
    Point GA{ 1.0, 2.0, 3.0 };
    Point GB{ 4.0, 5.0, 6.0 };
    Point GC{ 9.0, 8.0, 7.0 };
    Real  r        = 1.0;
    Real  thetaDeg = 45.0;
    Real  phiDeg   = 45.0;

    // Test data
    Sphere2Coord Sphere2;
    Sphere2.Compute (GA, GB, GC);
    Point originTest = Sphere2.GetOrigin ();

    // Target Data
    Point    originTarget{ 1.0, 2.0, 3.0 };
    Vector3D m_bases_0_Target{ 0.707107, 0.0, -0.707107 };
    Vector3D m_bases_1_Target{ -0.408248, 0.816497, -0.408248 };
    Vector3D m_bases_2_Target{ 0.577350, 0.577350, 0.577350 };

    // Check
    ASSERT_TRUE (originTest == originTarget);
    ASSERT_TRUE (Sphere2.GetBaseX () == m_bases_0_Target);
    ASSERT_TRUE (Sphere2.GetBaseY () == m_bases_1_Target);
    ASSERT_TRUE (Sphere2.GetBaseZ () == m_bases_2_Target);

    // Test Data
    auto golbalCoordTest = Sphere2.Trans2Basic (r, thetaDeg, phiDeg);

    // Target data
    Point golbalCoordTarget{ 1.557678, 2.816497, 2.850571 };

    // Check
    ASSERT_TRUE (golbalCoordTest == golbalCoordTarget);
}
